package demo;
//Day02
public class Day12001 {
    public static void main(String[] args) {
        Worker worker=new Worker();
        Dog dog=new Dog();
        Cat cat=new Cat();
        Pig pig=new Pig();
//        老板指挥员工给动物喂食
        worker.animalEat(dog);
        worker.animalEat(cat);
        worker.animalEat(pig);
    }
}
//动物类
class Animal{
    public void eat(){
        System.out.println("吃饭");
    }
}
//狗类
class Dog extends Animal{
    @Override
    public void eat() {
        super.eat();
        System.out.println("我是一只狗，我在吃肉！");
    }
}
//猫类
class Cat extends Animal{
    @Override
    public void eat() {
        super.eat();
        System.out.println("我是一只猫，我在吃鱼！");
    }
}
//猪类
class Pig extends Animal{
    @Override
    public void eat() {
        super.eat();
        System.out.println("我是一只猪，我没得吃！");
    }
}
//员工类
class Worker{
    public void animalEat(Animal animal){
        animal.eat();
    }
}